package com.drama.api.task;

import com.drama.api.base.RedisUtils;
import com.drama.api.company.dramas.dao.CompanyDramasDao;
import com.drama.api.company.message.dao.CompanyMessageDao;
import com.drama.api.company.video.dao.CompanyVideoDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ScheduledTask {
    @Autowired
    private CompanyVideoDao companyVideoDao;
    @Autowired
    RedisUtils redisUtils;
    @Autowired
    private CompanyMessageDao companyMessageDao;
    @Autowired
    private CompanyDramasDao companyDramasDao;



    @Value("${resource.add.api.url}")
    private String resource_server_url;
    @Scheduled(cron = "0 0 0 * * ?")// 每天凌晨执行
//    @Scheduled(cron = "0 * * * * ?")// 每5分钟
    public void dramStateTask(){
        new CompanyDramaThread(companyMessageDao,companyDramasDao).start();
    }

    @Scheduled(cron = "2 * * * * ?")// 每5分钟
    public void videoTask(){
        new CompanyVideoThread(companyVideoDao,redisUtils).start();
        new CompanyVideoExampleThread(companyVideoDao,redisUtils).start();
    }

//    @Scheduled(cron = "5 * * * * ?")// 每5分钟
//    public void CompanyVideoCroppingThreadTask(){
//        new CompanyVideoCroppingThread(companyVideoDao,redisUtils,resource_server_url,new RestTemplateUtils()).start();
//    }


}
